#include <iostream>
#include <string>
//
// Created by Asus on 2025/4/21.
//
namespace AnimalWorld {
    // base
    class Animal {
    public:
        std::string name;

        Animal(const std::string &name) : name(name) {
        }

        void introduce() const {
            std::cout << "I'm an animal named " << name << std::endl;
        }

    protected:
        int age;

    private:
        std::string species;
    };

    class Dog : public Animal {
    public:
        std::string bredd;

        Dog(const std::string &name, const std::string &bredd) : Animal(name), bredd(bredd) {
        }

        void bark() const {
            std::cout << "I'm a dog " << bredd << std::endl;
        }
    };
}

int main() {
    // 使用命名空间中的类创建指针对象
    AnimalWorld::Animal *genericAnimal = new AnimalWorld::Animal("Generic");
    genericAnimal->introduce();

    AnimalWorld::Dog *myDog = new AnimalWorld::Dog("Buddy", "Golden Retriever");
    myDog->introduce();
    myDog->bark();

    // 释放指针对象占用的内存
    delete genericAnimal;
    delete myDog;

    return 0;
}
